/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * thresholdTopik.java
 *
 * Created on 17 Mei 11, 11:42:34
 */

package taini;

import java.awt.Frame;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import taini.koneksi.KoneksiAini;

/**
 *
 * @author Aini
 */
public class thresholdTopik extends javax.swing.JFrame {

    double stdDevAll = 0.0;
    double meanAll = 0.0;
    double hasil = 0.0;
    String topikDokumen ="";
    int id_dok = 0;
    int id_topik = 0;
    KoneksiAini konek = new KoneksiAini();
    private String topikBaru = "";
    /** Creates new form thresholdTopik */
    public thresholdTopik() {

        initComponents();
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        JTFtc = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        JTFmeanTC = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        JTFstdDevA = new javax.swing.JTextField();
        JTFmeanA = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        JTFNewTSim = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        JTFCosSimTCA = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        JTFStdDevAllTopics = new javax.swing.JTextField();
        JTFMeanAllTopics = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTextField9 = new javax.swing.JTextField();
        jTextField10 = new javax.swing.JTextField();
        jTextField11 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jTextField12 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextField13 = new javax.swing.JTextField();
        duaKaliStdDevMeanAll = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel2.setText("| tc | :");

        JTFtc.setEditable(false);

        jLabel3.setText("Mean(tc)");

        JTFmeanTC.setEditable(false);

        jLabel5.setText("StdDev(A)");

        JTFstdDevA.setEditable(false);
        JTFstdDevA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFstdDevAActionPerformed(evt);
            }
        });

        JTFmeanA.setEditable(false);

        jLabel6.setText("Mean(A)");

        jLabel7.setText("NewTSim(tc, A)");

        JTFNewTSim.setEditable(false);
        JTFNewTSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFNewTSimActionPerformed(evt);
            }
        });

        jLabel8.setText("CosSim(tc,A)");

        JTFCosSimTCA.setEditable(false);
        JTFCosSimTCA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFCosSimTCAActionPerformed(evt);
            }
        });

        jLabel1.setText("Mean(AllTopicsSim)");

        jLabel4.setText("StdDev(AllTopicsSim)");

        JTFStdDevAllTopics.setEditable(false);

        JTFMeanAllTopics.setEditable(false);
        JTFMeanAllTopics.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFMeanAllTopicsActionPerformed(evt);
            }
        });

        jLabel9.setText("Thresholds:");

        jLabel10.setText("1.              CosSim(tc,A)                       >   0.3   ^                       CosSim(tc,A)                             >                         NewTSim(tc, A)");

        jTextField9.setEditable(false);

        jTextField10.setEditable(false);
        jTextField10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField10ActionPerformed(evt);
            }
        });

        jTextField11.setEditable(false);

        jLabel11.setText(">   0.1  ^");

        jLabel12.setText("    >");

        jLabel13.setText("2.             NumTopics                            >   10   ^                     CosSim(tc,A)                   >    (2xStdDev(AllTopicsSim)+Mean(AllTopicsSim))");

        jTextField12.setEditable(false);
        jTextField12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField12ActionPerformed(evt);
            }
        });

        jLabel14.setText(" >    10   ^");

        jTextField13.setEditable(false);

        duaKaliStdDevMeanAll.setEditable(false);

        jLabel15.setText("Kesimpulan :");

        jLabel16.setText("   ");

        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel17.setText("    >");

        jButton2.setText("Masukan ke Database");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 663, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 649, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(JTFNewTSim, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(JTFmeanA, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(JTFtc, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(JTFStdDevAllTopics, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(JTFmeanTC, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(JTFstdDevA, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(JTFCosSimTCA, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(JTFMeanAllTopics, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)))
                                .addGap(52, 52, 52))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(27, 27, 27)
                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jTextField10, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel12)
                                .addGap(29, 29, 29)
                                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(24, 24, 24))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField13, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel17)
                        .addGap(29, 29, 29)
                        .addComponent(duaKaliStdDevMeanAll, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(29, 29, 29))
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(38, 38, 38)
                        .addComponent(jButton1)
                        .addGap(31, 31, 31))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(JTFmeanTC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JTFstdDevA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(JTFCosSimTCA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JTFtc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JTFmeanA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(JTFNewTSim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JTFStdDevAllTopics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JTFMeanAllTopics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(18, 18, 18)
                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(duaKaliStdDevMeanAll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(19, 19, 19))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void setNilai(String nilai)
    {

            JTFCosSimTCA.setText(nilai);
            jTextField10.setText(nilai);
            jTextField9.setText(nilai);
            jTextField13.setText(nilai);
            


            
    }

    public void setId(int id)
    {
    this.id_dok = id;

    }
    public void setduaKaliStdDevMeanAll(double stddev, double mean)
    {
        double a = 2*stddev;
        double hasinya  = a + mean;
        duaKaliStdDevMeanAll.setText(String.valueOf(hasinya));

    }

   

    public void setjTextField12(int jumlah)
    {
    jTextField12.setText(String.valueOf(jumlah));
    }

    public void setStabdaDev(double stddev)
    {
        JTFStdDevAllTopics.setText(String.valueOf(stddev));

    }
    public void setMean(double mean)
    {
        JTFMeanAllTopics.setText(String.valueOf(mean));

    }
    private void JTFstdDevAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFstdDevAActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFstdDevAActionPerformed

    private void JTFCosSimTCAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFCosSimTCAActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFCosSimTCAActionPerformed

    private void JTFNewTSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFNewTSimActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFNewTSimActionPerformed

    private void jTextField12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField12ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField12ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:


        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void JTFMeanAllTopicsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFMeanAllTopicsActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_JTFMeanAllTopicsActionPerformed

    private void jTextField10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField10ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField10ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
              
        try {
            konek.connectFirst();

             if(this.topikBaru.equals(""))
             {
                 int iddok = 0;
                  try {
            konek.connectFirst();
            String ambiliddok = "SELECT MAX(ID_DOK) from DOKUMEN";
        ResultSet result = konek.executeSelect(ambiliddok);
        
        while(result.next())
        {
        iddok = Integer.parseInt(result.getString(1));
        }
        
        this.id_dok = iddok;
        System.out.println(this.id_dok);
        } catch (SQLException ex) {
            Logger.getLogger(thresholdTopik.class.getName()).log(Level.SEVERE, null, ex);
        }
                 
                 String updateTopik = "UPDATE Dokumen SET id_topik = "+this.id_topik+" WHERE id_dok = "+iddok+"";
             konek.executeUpdate(updateTopik);}
             else
             {
                int iddok = 0;
                  try {
            konek.connectFirst();
            String ambiliddok = "SELECT MAX(ID_DOK) from DOKUMEN";
        ResultSet result = konek.executeSelect(ambiliddok);

        while(result.next())
        {
        iddok = Integer.parseInt(result.getString(1));
        }

        } catch (SQLException ex) {
            Logger.getLogger(thresholdTopik.class.getName()).log(Level.SEVERE, null, ex);
        }
                
        this.id_dok = iddok;
        System.out.println(this.id_dok);
                String idTOpikMax = "SELECT MAX(ID_TOPIK) FROM TOPIK";
                int idmax = 0;
                ResultSet rs = konek.executeSelect(idTOpikMax);
                while(rs.next())
                {
                idmax = Integer.parseInt(rs.getString(1));
                }
                idmax = idmax +1;

                String updateTop = "INSERT INTO `taaini`.`TOPIK` (`ID_TOPIK`, `TOPIK`) VALUES ("+idmax+", '"+this.topikBaru+"');";
                konek.executeUpdate(updateTop);

               String updateDok = "UPDATE Dokumen SET id_topik = "+idmax+" WHERE id_dok = "+iddok+"";
               konek.executeUpdate(updateDok);



             }
             konek.destroyConnection();
 
        } catch (SQLException ex) {
            Logger.getLogger(thresholdTopik.class.getName()).log(Level.SEVERE, null, ex);
        }
            JOptionPane.showMessageDialog(new Frame(),"DOkumen berhasil dimasukkan ke database");
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new thresholdTopik().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField JTFCosSimTCA;
    private javax.swing.JTextField JTFMeanAllTopics;
    private javax.swing.JTextField JTFNewTSim;
    private javax.swing.JTextField JTFStdDevAllTopics;
    private javax.swing.JTextField JTFmeanA;
    private javax.swing.JTextField JTFmeanTC;
    private javax.swing.JTextField JTFstdDevA;
    private javax.swing.JTextField JTFtc;
    private javax.swing.JTextField duaKaliStdDevMeanAll;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField9;
    // End of variables declaration//GEN-END:variables

    public void setJTFmeanTC(double meanTC) {
        JTFmeanTC.setText(String.valueOf(meanTC));
    }

    void setJTFtc(double panjangTC) {
        JTFtc.setText(String.valueOf(panjangTC));
    }

    void setJTFmeanA(double meanDok) {
        JTFmeanA.setText(String.valueOf(meanDok));
    }

    void setJTFstdDevA(double SDDok) {
        JTFstdDevA.setText(String.valueOf(SDDok));
    }

    void setJTFNewTSim(double newTsim) {
        JTFNewTSim.setText(String.valueOf(newTsim));
        jTextField11.setText(String.valueOf(newTsim));
    }

    void cek() {
        int success = 0;
        Double cossim = 0.0;
        Double newtsim = 0.0;
        int numtop = 0;
        Double stddev2 = 0.0;
        
        
        cossim = Double.parseDouble(jTextField9.getText());
       // System.out.println(cossim);
        newtsim = Double.parseDouble(jTextField11.getText());
       // System.out.println(newtsim);
        numtop = Integer.parseInt(jTextField12.getText());
       // System.out.println(numtop);
        stddev2 = Double.parseDouble(duaKaliStdDevMeanAll.getText());
     //   System.out.println(stddev2);

        if(JTFtc.getText().isEmpty() || JTFmeanTC.getText().isEmpty() ||
           JTFmeanA.getText().isEmpty() || JTFstdDevA.getText().isEmpty() || JTFNewTSim.getText().isEmpty() ||
           JTFCosSimTCA.getText().isEmpty() || JTFStdDevAllTopics.getText().isEmpty() || JTFMeanAllTopics.getText().isEmpty())
        {

            success = 0;
        }
        else if((cossim > 0.3) && (cossim > newtsim)  )
        {
           
            success++;
//            System.out.println(success);
            if((numtop > 10)&& (cossim > stddev2))
            {
                    success++;
            }
            else
            {
                success = 1;
            }

            
          
        }
        else
        {
            success = 1;
        }


            System.out.println(success);


        if(success == 0)
        {
        jLabel16.setText("Masih terdapat data yang kosong, threshold tidak dapat dihitung");
        }
        else if(success == 1)
        {
        String topikSendiri = JOptionPane.showInputDialog( "Topik hanya memenuhi 1 threshold," +
                "\n maka harus diberi topik baru: " );
        jLabel16.setText("Topik dokumen tersebut: "+topikSendiri);
        this.topikBaru = topikSendiri;

        int id=0;
        String idTOpikBaru = "SELECT MAX(ID_TOPIK) FROM TOPIK";
            try {
                konek.connectFirst();
                ResultSet res = konek.executeSelect(idTOpikBaru);
                while(res.next())
                {
                id = Integer.parseInt(res.getString(1));
                }
                id = id+1;
                this.id_topik = id;
            } catch (SQLException ex) {
                Logger.getLogger(thresholdTopik.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalStateException ex) {
                Logger.getLogger(thresholdTopik.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
        else if(success == 2)
        {
        jLabel16.setText("Topik telah memenuhi kedua threshold \n maka topik "+this.topikDokumen+" sudah sesuai untuk dokumen");
        
        }

    }

    void setTopik(String textString) {
        this.topikDokumen = textString;
    }

    void setIdTopik(int idcari) {
        this.id_topik = idcari;
    }

}
